﻿using System;
using RayDen.Library.Core.Primitives;

namespace RayDen.Library.Entity.Scene {
    public class MaterialInfoData<TRadiance> {
        public TRadiance Ka;
        public TRadiance Kd;
        public TRadiance Ks;
        public TRadiance Kr;
        public TRadiance Kt;
        public TRadiance Ke;
        public float Exponent;

        public TextureInfo Alpha;
        public TextureInfo Diffuse;
        public TextureInfo Specular;
        public TextureInfo NormalMap;
        public TextureInfo BumpMap;

        public float IoR;
        public float Attenuation;
        public TRadiance IndexOfRefraction;

        public MaterialInfoData() { }

        public MaterialInfoData(MaterialInfo mi, Func<RgbSpectrum, TRadiance> conv)
        {
            this.Ka = conv(mi.Ka);
            this.Kd = conv(mi.Kd);
            this.Ks = conv(mi.Ks);
            this.Ke = conv(mi.Ke);
            this.Kr = conv(mi.Kr);
            this.Kt = conv(mi.Kt);
            this.Exponent = mi.Exponent;

            this.Alpha = mi.Alpha;
            this.Diffuse = mi.Diffuse;
            this.BumpMap = mi.BumpMap;
            this.Specular = mi.Specular;
            this.NormalMap = mi.NormalMap;

            this.IoR = mi.MediumInfo.IoR;
            this.Attenuation = mi.MediumInfo.Attenuation;
        }
    }
}